/*************************************************************************
	> File Name: P1683.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-04-16 14:03:12
 ************************************************************************/

#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

int m, n, ans = 1;
int dir[4][2] = {
    {-1, 0}, {1, 0}, {0, -1}, {0, 1}
};
bool vis[50][50];

void dfs(vector<string> &gride, int x, int y) {
    for (int k = 0; k < 4; k++) {
        int dx = x + dir[k][0];
        int dy = y + dir[k][1];
        if (dx < 0 || dx >= m || dy < 0 || dy >= n) continue;
        if (vis[dx][dy] || gride[dx][dy] == '#') continue;
        vis[dx][dy] = 1;
        ans += 1;
        dfs(gride, dx, dy);
    }
    return ;
}

int main() {
    cin >> n >> m;
    vector<string> gride(m);
    for (int i = 0; i < m; i++) {
        cin >> gride[i];
    }
    int x = 0, y = 0, flag = 1;
    for (int i = 0; flag && i < m; i++) {
        for (int j = 0; j < n; j++) {
            if (gride[i][j] == '@') {
                x = i, y = j;
                flag = 0;
                break;
            }
        }
    }
    vis[x][y] = 1;
    dfs(gride, x, y);
    vis[x][y] = 0;
    cout << ans << endl;
    return 0;
}
